<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>数组去重</title>
    <script>
        function check(arr) {
            return arr != 2
        }

        function remove(arr, x) {
            return arr.filter(check)

        }
        var arr = new Array(1, 2, 3, 4, 2, 5, 6, 2, 7, 2)
        document.write(arr + '<br/>')
        document.write('需求分析1题计算结果' + remove(arr, 2) + '<br/>')

        var array = new Array(4, 6, 0, 3, 0, 0, 0, 1, 3)
        var newArray = new Array()
        for (var i = 0; i < array.length; i++) {
            if (array[i] != 0) {
                newArray.push(array[i])
            }
        }
        document.write(array + '<br/>')
        document.write('需求分析2题计算结果' + newArray)
    </script>
</head>

<body>

</body>

</html>